package com.dizner.andandroidupdatetest

import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.os.Message
import kotlinx.android.synthetic.main.activity_luncher.*

class LuncherActivity : AppCompatActivity() {

    private  val mHandler = Handler(object : Handler.Callback {
        public override fun handleMessage(msg: Message): Boolean {
            when (msg.what) {
                1 -> {

                }
                2 -> {
                    index++
                    tv.text = index.toString()
                    startActivity(Intent(this@LuncherActivity, MainActivity::class.java))
                    finish()
                }
            }
            return false
        }
    })

    private var index: Int = 0

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_luncher)

    }

    override fun onResume() {
        super.onResume()
//        mHandler.sendEmptyMessage(1)
        mHandler.sendEmptyMessageDelayed(2, 1000)
    }
}
